-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make sure executeBatch returns error response for rows that would not get into database #503
Conversation
5d41b79
to
17d2a4a
Compare
17d2a4a
to
5d3255f
Compare
5d3255f
to
9b08f80
Compare
Current coverage is
|
9b08f80
to
9e9661f
Compare
@davecramer , @kjurka , @sehrope any volunteers to review the patch? I think the patch is ready. I've corrected behavior to silently accept SELECT statements in the batch set. I have no idea why it was rejected before. Is there a good reason to reject SELECTs in batch executions? |
Yes, this seems to work for me. In my test, it now returns -3 for all batch operations, and Oak (after removing the Postgres-specific workaround) copes with it. Note that the RDBDocumentStoreJDBCTest in oak trunk (that I mentioned previously) will have to be modified to accept the Postgres behavior (failing all parts of the batch). See https://issues.apache.org/jira/browse/OAK-3977. |
} catch (SQLException e) { | ||
fail("Should throw a BatchUpdateException instead of " + "a generic SQLException: " + e); | ||
updateCounts = stmt.executeBatch(); | ||
fail("0/0 should throw BatchUpdateException"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is division by zero
I'll refactor Something like that enum AutoCommit {
YES, NO;
}
enum GeneratedKey {
YES, NO;
}
enum FailMode {
NO_FAIL, FAIL_VIA_SELECT, FAIL_VIA_DUP_KEY
}
enum FailPosition {
FIRST_ROW, SECOND_ROW, LAST_ROW, ALMOST_LAST_ROW
} |
if (latestGeneratedRows != null) { | ||
// We have DML. Decrease resultIndex that was just increased in handleResultRows | ||
resultIndex--; | ||
// If seen exception, no need to collect generated keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is better worded as If exception thrown...
9e9661f
to
7f9a34d
Compare
7f9a34d
to
966d952
Compare
966d952
to
c29ad2b
Compare
c29ad2b
to
ae8fcac
Compare
ae8fcac
to
d6e3b17
Compare
This fix seems to break the following I have a few insert statements batched for improving performance. With update count returning for whatever succeeded I had a chance to ignore the failed ones and try again the succeeded ones. Now there is no clue which one in the batch actually caused BatchUpdateException as it returns -3 for all inserts Should executeBatch consider the failed ones as the changes anyway get rolled back if I roll back the transaction leaving no scope of partial commit? |
@jkprasad , to my best understanding, JDBC specification provides no way to identify the row that caused the failure. The suggested behavior is to retry rows with |
@vlsi Million thanks for the quick reply. |
That depends on the |
Previously, executeBatch did not consider that under error condition, a part of the batch might get rolled back.
closes #502